package com.platform.module.common.base;


import io.swagger.v3.oas.annotations.media.Schema;

@Schema(description = "响应对象")
public class Response {
    @Schema(
            description = "响应code码 ，0成功，1失败，2异常,9未登录，10无权限，-1不允许操作",
            requiredMode = Schema.RequiredMode.REQUIRED,
            example = "1"
    )
    private String code;
    @Schema(
            description = "响应消息",
            requiredMode = Schema.RequiredMode.REQUIRED
    )
    private String msg;
    @Schema(
            description = "响应消息",
            requiredMode = Schema.RequiredMode.REQUIRED
    )
    private Long serverTime;

    public Response(String code, String msg) {
        this.code = CodeDict.SUCCESS.getCode();
        this.msg = CodeDict.SUCCESS.getMsg();
        this.serverTime = System.currentTimeMillis();
        this.code = code;
        this.msg = msg;
        this.serverTime = System.currentTimeMillis();
    }

    public Response(CodeDict code) {
        this.code = CodeDict.SUCCESS.getCode();
        this.msg = CodeDict.SUCCESS.getMsg();
        this.serverTime = System.currentTimeMillis();
        this.code = code.getCode();
        this.msg = code.getMsg();
        this.serverTime = System.currentTimeMillis();
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Long getServerTime() {
        return this.serverTime;
    }

    public void setMsg(Long serverTime) {
        this.serverTime = serverTime;
    }

    public Response() {
        this.code = CodeDict.SUCCESS.getCode();
        this.msg = CodeDict.SUCCESS.getMsg();
        this.serverTime = System.currentTimeMillis();
    }
}
